package com.cci.kangdao.entity;

import com.cci.kangdao.utilTool.LocalTimeUtil;
import org.apache.log4j.Logger;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class LatestWorkOrder {
	
	private Logger log = Logger.getLogger(LatestWorkOrder.class);
	
	private static final String pattern = "yyyy-MM-dd HH:mm:ss";
	
	private String esn;
	
	private Integer orderStatus;
	
	private String createTime;
	
	
	public String getEsn() {
		return esn;
	}

	public void setEsn(String esn) {
		this.esn = esn;
	}

	public Integer getOrderStatus() {
		return orderStatus;
	}

	public void setOrderStatus(Integer orderStatus) {
		this.orderStatus = orderStatus;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	
	/**
	 * 判断当前服务工单的创建时间是否超时24小时
	 */
	public boolean isMoreThan24Hours() {
		
		LocalDateTime orderCreateTime = LocalDateTime.parse(this.createTime, DateTimeFormatter.ofPattern(pattern));
		LocalDateTime nowTime = LocalDateTime.parse(LocalTimeUtil.getRealCurrentTime(), DateTimeFormatter.ofPattern(pattern));
		// 工单的创建时间增加24小时
		LocalDateTime  timeOfPlus = orderCreateTime.plusDays(1);
		// 工单的创建时间增加24小时后,如果小于当前时间，说明订单的创建时间超时24小时
		log.info(String.format("订单创建时间：%s  服务器时间：%s", orderCreateTime, nowTime));
		return timeOfPlus.isBefore(nowTime);
	}

}
